package com.study.leetcode;

import java.util.ArrayList;
import java.util.List;

public class Solution_2178 {
    public static List<Long> maximumEvenSplit(long finalSum) {
        List<Long> res = new ArrayList<>();
        if (finalSum % 2 != 0) {
            return res;
        }
        long i = 2;
        while (finalSum > 0) {
            if (finalSum - i >= 0) {
                res.add(i);
                finalSum -= i;
                i += 2;
            } else {
                break;
            }
        }
        if (finalSum != 0) {
            res.set(res.size() - 1, res.get(res.size()-1) + finalSum);
        }
        return res;
    }

    public static void main(String[] args) {
        List<Long> list = maximumEvenSplit(28);
        System.out.println("list = " + list);
    }
}
